<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/7/11 0011
  Time: 下午 4:48
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<html>
<head>
    <title>Title</title>

    <script src="../../js/jquery-3.3.1.min.js" charset="utf-8"></script>
    <script src="../../js/cookie/jquery.cookie.js" charset="utf-8"></script>
    <script src="../../layui-v2.2.5/layui/layui.js" charset="utf-8"></script>
    <link rel="stylesheet" href="../../layui-v2.2.5/layui/css/layui.css" media="all">
</head>
<body>

<table class="layui-hide" id="test"></table>

<div style="margin-bottom: 5px;">
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right;margin-right: 100px"  href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
    <!-- 示例-970 -->
    <ins class="adsbygoogle" style="display:inline-block;width:970px;height:90px" data-ad-client="ca-pub-6111334333458862" data-ad-slot="3820120620"></ins>
    已开通商家数量/总数量
    <div class="layui-progress" lay-showPercent="true">
        <div class="layui-progress-bar layui-bg-red" lay-percent="${data.now}/${data.all}"></div>
    </div>
</div>
<c:if test="${sessionScope.userType==1}">
    <c:if test="${data.all>data.now}">
        <button class="layui-btn" onclick="addOrg()">添加商户</button>
    </c:if>
    <c:if test="${data.all<=data.now}">
        您可开通的商户数量已达上限，请联系管理员续费升级
    </c:if>
</c:if>


<%--<div class="layui-btn-group demoTable">--%>
    <%--<button class="layui-btn" data-type="getCheckData">获取选中行数据</button>--%>
    <%--<button class="layui-btn" data-type="getCheckLength">获取选中数目</button>--%>
    <%--<button class="layui-btn" data-type="isAll">验证是否全选</button>--%>
<%--</div>--%>

<table class="layui-table" lay-data="{width: 1800, height:600, url:'/marketing/orgListData', page:true, id:'idTest'}" lay-filter="demo">
    <thead>
    <tr>
        <th lay-data="{type:'checkbox', fixed: 'left'}"></th>
        <th lay-data="{field:'id', width:80,  fixed: true}">ID</th>
        <th lay-data="{field:'name', width:180}">商户名称</th>
        <th lay-data="{field:'address', width:360}">公司地址</th>
        <th lay-data="{field:'tel', width:120, }">商户电话</th>
        <th lay-data="{field:'person', width:120}">商户负责人</th>
        <th lay-data="{field:'userCode', width:160}">商户账号</th>
        <th lay-data="{field:'createTime', width:200}">创建时间</th>
        <th lay-data="{fixed: 'right', width:178, align:'center', toolbar: '#activityActivityList'}">活动管理</th>
        <%--<th lay-data="{fixed: 'right', width:178, align:'center', toolbar: '#voucher'}">代金券</th>--%>
        <th lay-data="{fixed: 'right', width:178, align:'center', toolbar: '#barDemo'}">操作</th>
    </tr>
    </thead>
</table>
<%--<script type="text/html" id="voucher">

    <a class="layui-btn layui-btn-xs" lay-event="voucherEdit">设置代金券</a>
</script>--%>
<%--<script type="text/html" id="rebateStting">--%>
    <%--<a class="layui-btn layui-btn-xs" lay-event="rebateStting">返利设置</a>--%>
<%--</script>--%>


<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit" <c:if test="${sessionScope.userType==2}">  style="display:none"  </c:if> >编辑信息</a>
    <%--<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>--%>
</script>
<script type="text/html" id="activityActivityList">
    <a class="layui-btn layui-btn-xs" lay-event="activityActivityList">活动信息</a>
</script>

<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>

    layui.use('element', function(){
        var element = layui.element;
    });

    layui.use('table', function(){
        var table = layui.table;
        //监听表格复选框选择
        table.on('checkbox(demo)', function(obj){
            console.log(obj);
        });
        //监听工具条
        table.on('tool(demo)', function(obj){
            var data = obj.data;
            if(obj.event === 'detail'){
                layer.msg('ID：'+ data.id + ' 的查看操作');
            } else if(obj.event === 'del'){
                layer.confirm('真的删除行么', function(index){
                    obj.del();
                    layer.close(index);
                });
            } else if(obj.event === 'edit'){//
                //layer.alert('编辑行：<br>'+ JSON.stringify(data));
                $.cookie("orgDate",JSON.stringify(data));
                layer.open({
                    type: 2,
                    title:"机构信息",
                    shadeClose:true,
                    area: ['65%', '65%'],
                    content: '/marketing/goEditOrgInfo?id='+obj.data.id,
                    end:function () {
                        window.location.reload();
                    }
                });
            }else if (obj.event=='voucherEdit'){
                layer.open({
                    type: 2,
                    title:"优惠券",
                    shadeClose:true,
                    area: ['90%', '90%'],
                    offset: '0px',
                    content: '/marketing/goVoucherList?orgId='+obj.data.id,
                    end:function () {
                        window.location.reload();
                    }
                });
            }else if (obj.event=='activityActivityList'){
                layer.open({
                    type: 2,
                    title:"活动信息",
                    shadeClose:true,
                    offset: '0px',
                    area: ['95%', '95%'],
                    content: '/group/groupActivityList?orgId='+obj.data.id,
                    end:function () {
                        window.location.reload();
                    }
                });
            }else if(obj.event=='rebateStting'){
                layer.open({
                    type: 2,
                    title:"返利设置",
                    shadeClose:true,
                    offset: '30px',
                    area: ['50%', '50%'],
                    content: '/marketing/configRule?orgId='+obj.data.id,
                    end:function () {
                        window.location.reload();
                    }
                });
            }
        });

        var $ = layui.$, active = {
            getCheckData: function(){ //获取选中数据
                var checkStatus = table.checkStatus('idTest')
                    ,data = checkStatus.data;
                layer.alert(JSON.stringify(data));
            }
            ,getCheckLength: function(){ //获取选中数目
                var checkStatus = table.checkStatus('idTest')
                    ,data = checkStatus.data;
                layer.msg('选中了：'+ data.length + ' 个');
            }
            ,isAll: function(){ //验证是否全选
                var checkStatus = table.checkStatus('idTest');
                layer.msg(checkStatus.isAll ? '全选': '未全选')
            }
        };

        $('.demoTable .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });

/*添加机构*/
        function addOrg() {
            $.cookie("orgDate",null);
            layer.open({
                type: 2,
                title:"机构信息",
                shadeClose:true,
                offset: '30px',
                area: ['75%', '75%'],
                content: '/marketing/goEditOrgInfo?orgId=${orgId}',
                end:function () {
                    window.location.reload();
                }
            });
        }



</script>





</body>
</html>
